package com.treeman.marker;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.treeman.user.User;

@Entity
@Table(name = "MARKER")
public class Marker {

	public enum MarkerType {
		ACCIDENT, RADAR, TRAFFIC, PLACE, ADVERT
	}

	@Id
	@Column(name = "MARKER_ID")
	@SequenceGenerator(name = "marker_id_gen", sequenceName = "marker_id_sequence", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "marker_id_gen")
	private Long id;

	@Basic(optional = false)
	@Column(name = "NAME", nullable = false)
	private String name;

	@Column(name = "DESCRIPTION")
	private String description;

	@Column(name = "ADDRESS")
	private String address;

	@Column(name = "LONGITUDE")
	private Double longitude;

	@Column(name = "LATITUDE")
	private Double latitude;

	@Enumerated(EnumType.STRING)
	@Basic(optional = false)
	@Column(name = "TYPE", nullable = false)
	private MarkerType type;

	@Basic(optional = false)
	@ManyToOne(targetEntity = User.class)
	@JoinColumn(name = "USER_ID", nullable = false)
	private User author;

	@Basic(optional = false)
	@Column(name = "CREATED", nullable = false)
	private Date created;

	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public MarkerType getType() {
		return type;
	}

	public void setType(MarkerType type) {
		this.type = type;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}
}
